Spatial contagion during the first wave of the COVID‐19 pandemic: Some lessons from the case of Madrid, Spain

Abstract This paper analyses the magnitude of the spatial transmission of COVID‐19 through the municipalities of the region of Madrid during the first pandemic wave using a spatial contagion index. The study also provides additional insights into the main factors contributing to the spread of the virus in both time and space by estimating a novel conditional spatial contagion index. Our results reveal high values of spatial contagion before and during the national lockdown enacted on 15 March 2020, becoming medium/low since then. Furthermore, the study confirms the leading role of inter‐municipal mobility and population density in spatial contagion.

infection on the basis of clinical and ecological studies. Although the results are mixed, many of these studies confirm the disproportionate impact of COVID-19 in the most deprived communities, especially in certain demographic groups such as the elderly and certain ethnicities, and in territories with low income levels (Plümper & Neumayer, 2020;Ribeiro et al., 2020). Recent literature also reveals the significant role of urban population share, tourism, CO 2 emissions, high average temperatures and human mobility in explaining COVID-19 outbreaks (Bijari et al., 2021;Hâncean et al., 2020). Another point of interest emerging from this branch of the literature is related to the important distinction between population and population density. While some studies conclude that infections are significantly correlated not with density but with population levels (e.g., Boterman, 2020), other empirical studies reveal a positive relationship between population density of the different areas and COVID-19 incidence (Buja et al., 2020;Mogi & Spijker, 2021). As Desmet and Wacziarg (2020) indicate, the way population density is measured strongly affects the results obtained.
In any event, as far as the study of the pandemic is concerned, it is meaningful to point out that something differentiates the health crisis unleashed by COVID-19 from previous crises, such as those caused by an ordinary economic shock: it does not distinguish between territories. We are talking about a virus with a vast capacity for contagion between people, which ends up spreading contagion between territories. In other words, the geographical mobility of people (whether for work, leisure or other reasons) facilitates the transmission of the virus between territories, with the intensity of the contagion process depending, as we shall see and in line with some previously mentioned papers, not only on the degree of mobility of its population but also, to a greater or lesser degree, on the characteristics of the territory. These factors make the COVID-19 pandemic a complex phenomenon, to which no territory is immune, and in which spatial interactions undoubtedly play an important role.
In this framework, the use of spatial econometric techniques provides a very powerful tool to address the main spatio-temporal patterns of COVID-19 spread. Moreover, such techniques can be used to oversee the design and implementation of measures aimed at curbing the spread of the disease and, more importantly, to assess the importance of emerging hotspots of COVID-19 that should be closely monitored to prevent further expansion of the virus through and/or between territories. Accordingly, spatial econometric tools have been widely employed in recent years when dealing with this topic. We can cite the studies by Maza and Hierro (2021), Paez et al. (2021), Arenas et al. (2020), Cordes and Castro (2020), Dehghan and Shahnazi (2020), Ghosh and Cartone (2020), Guliyev (2020), Kang et al. (2020), Krisztin et al. (2020) and Orea and Alvarez (2020), among many others. The most notable and predictable conclusion of all these studies is that space, that is, the geographic location of the units of analysis, clearly matters.
This paper seeks to contribute to the growing body of literature addressing the dimension and main drivers of the spatial spread of COVID-19, but from a different angle: quantifying spatial contagion and analysing, on the basis of that measure, the importance of various factors in explaining it. To do so, it uses municipal-level data for the region of Madrid during the first pandemic wave (6 March to 21 June 2020), a critical period that has not been sufficiently covered by the extant literature. As the increasing concern about the emergence of new pandemics is becoming a prominent theme in both public and academic discourses (Telenti et al., 2021), this study may be fruitful for the management of forthcoming pandemics, especially in the initial phases to quickly contain the spread of a virus in the absence of a vaccine, or even, as is happening at the time of writing, in situations like the current one in which the efficacy of a vaccine in stopping the propagation of a disease is limited.
Specifically, in the first part of the paper, we resort to the concept of spatial contagion defined by Hierro et al. (2013) on the grounds of a spatial Markov chain approach, adapted here to the case of an epidemiological disease. This concept is particularly attractive as it goes far beyond a simple measure of community transmission. It refers to contagion between territories over time. More precisely, it considers territories that may be more likely exposed to a spatial/geographical contagion process, that is, those that are surrounded by others with a significant contagion capacity. It is, therefore, a concept that informs us on how spatial interactions contribute to the spread of the virus from high-to low-incidence areas throughout a region. As a further contribution, in the second part of the paper, we extend this approach by defining a new measure of conditional spatial contagion that allows us to evaluate the role played by some potential drivers in the virus propagation, such as inter-municipal mobility (see below), population (number of inhabitants), population density (inhabitants per squared kilometre), income (gross disposable income) and immigration (stock of foreign population). To our knowledge, this is the first study to assess the scale and key drivers of COVID-19 spatial contagion.
Another relevant contribution and a key strength of the study lies in the use of novel mobility data (recorded from mobile phones) provided by the Spanish National Statistical Institute (INE). These data are rich enough to allow us to address in detail the influence of inter-municipal mobility on spatial contagion processes. The main value of these data is that they enable us to assess the effect of all types of mobility on spatial contagion processes, including commuting, shopping trips and leisure. Thus, we join other researchers who have used mobile positioning data to analyse the impact of mobility on the COVID-19 propagation in countries such as Italy and Brazil, among many others (Peixoto et al., 2020;Pepe et al., 2020).
The remainder of this paper is as follows. Section 2 introduces the case study and the dataset. The methodology is explained in Section 3, while the results are presented in Section 4. The paper concludes in Section 5 with a summary of the main lessons learned in the light of the evidence collected in this paper.

| Case study
The study area comprises the region of Madrid (Spain) at the municipal level. Specifically, we deal with the different phases of the first pandemic wave, with special emphasis on the role played by the mobility of people between municipalities. The case study is particularly relevant since Madrid is deemed the 'epicentre' of the pandemic in Spain, with a balance of 69,732 confirmed cases and 8,369 deaths between 6 March and 21 June 2020, accounting for over 26% and 29% of the total figures in Spain, respectively. Nor can we disregard that, despite its widely recognized health services, Madrid's health care system shouldered the highest pressure across the country.
It was the end of February 2020 when the circulation of the virus became evident in the region of Madrid. Faced with an escalation of cases, the president of the region introduced, in early March, some social distancing measures, such as the suspension of classroom teaching in schools and universities, and the prohibition of family visits to nursing homes. A few days later, on 15 March, the Spanish government decreed a national lockdown to battle the coronavirus, marking the beginning of the so-called state of alarm. All non-essential shops were forced to close, and mobility was restricted to the purchase of essentials and urgent medical assistance. One week later, on 23 March, the collapse of Madrid's hospitals and intensive care units (ICUs) urged the regional government to erect (in less than 48 h) a kind of field hospital at the Instituci on Ferial de Madrid (IFEMA) conference centre, designed to host 5,500 hospital beds and 500 intensive care beds.
Although the national lockdown was initially envisaged for 2 weeks, the tragic death toll forced the Spanish government to extend it for an additional 4 weeks. As Figure 1 shows, the huge gap between the 14-day cumulative incidence (defined as the number of cumulative cases reported in the last 14 days per 100,000 inhabitants) in Madrid and Spain 1 became disturbingly large at the height of the health crisis, with the incidence in Madrid lying very close to the critical threshold of 500 (almost double the national average). It is clear, therefore, that Madrid acted as the first major focus of the virus in Spain. After 6 weeks of strict lockdown marred by dramatic and brutal numbers of fatalities in both the region and the whole country, the Spanish government designed a coordinated plan to pave the way towards a kind of normalcy in which clampdowns were progressively loosened in an orderly fashion. In this manner, the so-called de-escalation phase began, conducted in three-phased stages. Thereafter, the cumulative

| Variables, data sources and sample period
Our main variable of analysis is the 14-day cumulative incidence of confirmed COVID-19 cases (defined above), herein denoted by CI. This variable is calculated using data on daily counts of confirmed cases at the municipal level collected from the Open Data Portal of the Community of Madrid. Specifically, we gather information for 178 municipalities, as well as for the 21 districts that compound the metropolitan area of the municipality of Madrid.
Here it is necessary to clarify that the region of Madrid is made up of 179 municipalities, although the one with the same name as the region is clearly, in both extension and population, an outlier. For this reason, we collect information for the remaining 178 municipalities, as well as for the 21 districts that compound the municipality of Madrid.
To unveil the main drivers of spatial contagion, we also collected data on inter-municipal mobility, population, population density, gross disposable income and immigrant population. For other potential drivers mentioned in the Introduction, such as CO 2 emissions, temperature and so on, either there are no data at the municipal level or the differences between municipalities are not significant. Data on inter-municipal mobility consist of mobility registered over the previous 14 days, in an analogous fashion as our measure of cumulative incidence. This aspect is extremely relevant because it is well recognized that the peaks of virus prevalence during the lockdown were the natural consequence of the high mobility that occurred in the previous weeks. To estimate this variable, we exploit data on inter-municipal mobility, as well as inter-district mobility (for some relatively big municipalities) and inter-census The sample period starts on 6 March 2020, as this is the first day before the declaration of the national lockdown with more than one municipality with a 14-day cumulative incidence of confirmed COVID-19 cases per 100,000 inhabitants over 25 [threshold from which risk of contagion exists according to the European Centre for Disease Prevention and Control (ECDC)], and extends to 21 June 2020, the last day of the state of alarm. This implies a sample of 108 days across 199 spatial units (namely 178 municipalities plus the 21 districts that make up the municipality of Madrid). According to the different stages of the first wave mentioned above, we divide the entire period into five sub-periods: before lockdown, lockdown, de-escalation (phase 0), de-escalation (phase 1) and de-escalation (phase 2).

| Spatial dependence
To formally test for the existence of spatial interactions in the virus propagation, we resort to the well-known Moran's I statistic, which can also be represented graphically in what is known as the Moran's scatterplot. To do so, we first pre-define the spatial connectivity structure of the sample through the so-called spatial weights matrix W, with generic elements w ij called spatial weights. In our case, w ij is defined as the inverse of the distance between centroids of municipalities i and j, so that interactions between them decay inversely with distance. 2 As is convention, we use standardized spatial weights, so that each element of matrix W is divided by its row sum. The Moran's I statistic at a given time t reads as follows: where CI i (CI j ) is the cumulative incidence at municipality i (j), CI refers to the sample mean and n is the total number of municipalities.

| Spatial contagion index
As mentioned before, we adapt the notion of spatial contagion proposed by Hierro et al. (2013). Specifically, here we tackle situations in which municipalities surrounded by others with relatively high COVID-19 incidence (those with higher-than-average cumulative incidence values) move towards higher cumulative incidence levels.
Consequently, to construct our measure of spatial contagion, we first need to define the spatial lag for each municipality i. It is computed as the weighted-average cumulative incidence in neighbouring municipalities, that is, Þ, so that we can identify municipalities surrounded by others with a higher-than-average cumulative incidence. The rationale behind this notion is to integrate space into virus transmission by deriving a weighted average of the neighbouring observations.
Then, let us suppose a modified spatial Markov chain approach 3 in which municipalities surrounded by others of high incidence at t (namely municipalities with a spatial lag variable above the regional average at t, denoted hereafter by k) 4 are grouped into a finite number of exhaustive and mutually exclusive states S ¼ s i j ð Þ : i,j ¼ 1,2, …, r È É according to their cumulative incidence at times t and t þ z, so that X k t ð Þ and X tþ z ð Þ represent the cumulative incidence state/interval occupied by them at time t and t þ z, respectively. Then, we can define the spatial transition probability between a cumulative incidence state s i to another s j between t and t þ z as: In other words, if we consider the cumulative incidence state s i , then p s i s j jk t, t þ z ð Þwill give us the probability of municipalities within that state, surrounded by above-average incidence municipalities at time t, of moving towards the state s j . All the spatial transition probabilities are gathered in the so-called spatial transition matrix P k t, t þ z ð Þ .
Accordingly, the spatial contagion index for the period t, t þ z ð Þ , denoted as C k , can be defined as follows: where p sijk t ð Þ represents the initial proportion of municipalities surrounded at t by high-incidence areas and grouped in s i 's cumulative incidence state 5 ; p sisjjk t, t þ z ð Þ are the spatial transition probabilities defining upward mobility (s j > s i ); and, finally, d sisjjk t ð Þ, the generic element of a distance matrix D k t ð Þ, is a distance measure between states s i and s j that captures how far a cumulative incidence state is from another at time t, and defined as the difference in average cumulative incidence of the states considered. To get a normalized index, distances d sisjjk t ð Þ are divided by the largest value in the s i 's row of D k t ð Þ. By construction, the spatial contagion index ranges between zero and one: the closer its value is to one, the higher the level of spatial contagion.
From Equation 3, we can deduce for each state s i what could be called a state-by-state spatial contagion index as: which captures the contribution of each state to the spatial contagion process.

| Conditional spatial contagion index
As for the main factors that can expose municipalities surrounded by areas with relatively high COVID-19 incidence to higher levels of cumulative incidence over time, in this paper we propose a conditional/weighting scheme based on the estimation of spatial transitional probabilities conditional on a factor f that can potentially influence spatial contagion, that is, p f si,sjjk t, t þ z ð Þ . The rationale is as follows: rather than simply considering the number of municipalities moving from one state to another in the estimation of the transition probabilities, we now use additional information coming from the conditioning factor. As a result, we will have two spatial contagion indexes: one unconditional (the previous C k Þ and another conditional (C kjf Þ.
Therefore, the influence of a factor on spatial contagion would be reflected in the differences between the two indexes. If a factor had no importance on municipal movements across the cumulative incidence intervals, values for the conditional and unconditional transition probabilities should be roughly the same, and consequently, other things being equal, values for the unconditional and conditional spatial contagion indexes should be equal as well.
Otherwise, if the conditional index were significantly lower (higher) than the unconditional, one would have to conclude that spatial contagion and the conditioning factor f are related, the relationship being negative (positive).
By way of synthesis, Figure 2 displays a flow chart describing the main steps of our approach.

| Spatial distribution of the virus: Spatial dependence
To get a first glimpse of how the spread of the virus evolved in Madrid, Figure 3 shows the geographical distribution of the cumulative incidence by municipality over the sub-periods considered. The sequential comparison of the maps perfectly illustrates the uncontrolled propagation of the pandemic in Madrid (with progressively darker maps) until well into phase 0 of de-escalation, with the spread of the disease slowing down thereafter (with increasingly lighter maps). Without being exhaustive, three key conclusions merit special attention. First, as Figure 3b shows, on the day the lockdown officially began, the virus was already widespread throughout most of the region, with 54% of territories with a cumulative incidence higher than 25 cases per 100,000 inhabitants. In fact, some hotspots of a high incidence of COVID-19 had already emerged, although still very scattered. These findings inevitably raise the question: was the establishment of the lockdown too late? In our opinion, the figures seem to support an affirmative answer, at least as far as Madrid, the focus of the pandemic in Spain from day 1, is concerned. Second, the slowdown and subsequent stabilization of the transmission of the virus were not achieved until well into phase 1 of the de-escalation (late May). In our view, this seems to reveal the merit of extending phase 0 to control the spread of the virus and thus prevent it from flaring up again. Third, Figure 3 seems to convey the idea that the cumulative incidence of COVID-19 is not randomly distributed among municipalities. To be more precise, it seems to be closely related to that in their neighbouring municipalities, especially in some sub-periods. The clearest case of spatial clustering is illustrated, in the centre of the maps, by the districts that make up the municipality of Madridrecall that we divided it by size and populationand its adjacent municipalities during the lockdown phase.
Our last conclusion is, however, speculative at best, and should be tested statistically. Hence, we resort here to the Moran's I statistic. Table 1 presents this statistic for some representative dates throughout the period of analysis.
F I G U R E 2 Main steps in the identification of factors that may influence spatial contagion processes As can be seen, its sign is positive and statistically significant only from well into the lockdown phase until before the end of the de-escalation phase 0, so the existence of spatial association was restricted to part of our sample period.
Our study provides support to the expected link between these results and the spatial contagion processes we will address later.
Next, we turn to the Moran's scatterplot shown in Figure 4, as it is a useful graphical tool that allows us to visualize more intuitively the spatial association patterns revealed by the Moran's I statistic (Anselin, 1995). It charts the spatial lag on the vertical axis and the value at each location on the horizontal axis, both at time t. The four quadrants in the plot correspond to different types of spatial association. For example, the first quadrant (upper left) represents a negative association of municipalities with low cumulative incidence surrounded by others with high cumulative incidence, while the upper-right quadrant represents a positive association of high values. This graphical tool, F I G U R E 3 Cumulative incidence of COVID-19 in Madrid by municipality Note: As indicated in the legend, different shades correspond to different 14-day cumulative incidence intervals of confirmed COVID-19 cases per 100,000 inhabitants however, provides only a static picture of the issue at hand, so we will include some dynamics by looking at different dates. For the sake of simplicity, Figure 4  By comparing the position of the points in the sequential Moran's scatterplots, we can observe important changes from the upper-left to the upper-right quadrant, suggesting that many spatial contagion processes took place during the first COVID-19 wave, especially in its first half. In any case, caution is required because a cursory glance at Figure 4 is not enough to draw solid conclusions. It can be deemed as a preliminary overview that provides, F I G U R E 4 Cumulative incidence of COVID-19 in Madrid: Moran's scatterplot Note: Rhomboid-shaped black dots represent influential points ('inliers') nevertheless, some intuition on the issue at hand. Thus, the next aim is, on the one hand, to give a measure of the intensity of the contagion and, on the other, to unveil some of its driving factors.

| Intensity of contagion: Spatial contagion index
For this purpose, we first present in Table 2 the spatial transition matrices, P k t,t þ 7 ð Þ , the relative size of the states, p sijk t ð Þ, the state-by-state spatial contagion indexes, C si k t, t þ 7 ð Þ , and, finally, the spatial contagion index, C k t, t þ 7 ð Þ , for the five sub-periods into which we divided our period, as well as for the whole one. Before commenting on the results, it is worth making some preliminary considerations on the definition of the states and the length of the transition period, since both must be pre-determined by the researcher. As for the states, in our case intervals of CI, choosing neither a very short nor a very long length for transitions. This is because the former would imply very limited mobility, while a too long one would lead to a significant loss of observations. Under the above premise and considering that the analysis of the spatial spread of a virus requires a minimum time frame (of at least, we think, 1 week), we opt for a 7-day transition period (z ¼ 7).
It should be noted that upward spatial transition probabilities are grey-shaded in Table 2, as they are the ones relevant to the estimation of the spatial contagion index. 6 We find that the highest spatial transition probability just before the lockdown (of 0.667) implies that those municipalities that were surrounded by others with high incidence and labelled as 'low risk' moved to a situation labelled as 'high risk' after 7 days. In any case, this situation was, according to the value of p sijk t ð Þ, merely marginal, since it represented only 1.7% of the municipalities surrounded by others with high incidence. Not surprisingly, during the days prior to the declaration of the lockdown, almost all municipalities (97.1%) started from an idyllic situation of 'lack of risk'. As is also shown by the row corresponding to p s i jk t ð Þ in Table 2, this situation was reversed during the lockdown, being re-established, although to a lesser extent, during the following phases. Also noteworthy is the existence of positive upward spatial transition probabilities from most of the intervals towards intervals representing a very high or even extreme risk of contagion during the lockdown (marked in bold), this being a critical condition for the contagion index to reach very high values (even more so if accompanied by high values of p sijk t ð Þ) as evidence of a very rapid spread of the disease in a short period of time.
Concerning the spatial contagion index, we see that its value is very close to zero in all cases. At first glance, this may appear somewhat odd. However, a correct interpretation requires going beyond the theoretical range of values (0-1), since a value of 1 would arise only if 'all' transitions were movements towards the most distanced cumulative incidence state, in our case (500,þ∞), which is virtually impossible. Thus, for a proper interpretation of the scale of the index, following Hierro et al. (2013) we carried out a number of simulations to distinguish, from a more realistic perspective, between what we consider can be categorized as high, medium and low degrees of spatial contagion.
We adopted the following criteria: we labelled a situation as 'high spatial contagion' if C k is over 0.0389 (obtained, on average, when 25% of municipalities move to the contiguous state); 'medium spatial contagion' if C k is between 0.0389 and 0.0156 (the last threshold obtained when 10% of the municipalities move to the contiguous state); and 'low spatial contagion' if C k is below 0.0156. Accordingly, the information provided by Table 2 indicates that spatial contagion reached high values before and during the lockdown, while values were close to the boundary between medium and low contagion throughout the three de-escalation phases. It should also be noted that, although the intensity of contagion decreased by nearly 20% during the lockdown, the greatest decrease (80%) occurred at the beginning of the de-escalation phase, stabilizing afterwards until the end of the state of alarm. Consequently, our 6 As seen in equation 3, the spatial contagion index is defined for sj > si because only transitions to intervals of higher cumulative incidence are involved in a process of spatial contagion.
T A B L E 2 Cumulative incidence of COVID-19 in Madrid: Spatial transition matrices and spatial contagion indexes a) Before lockdown (k   results show that, despite the long lockdown undergone in Madrid, spatial contagion processes did not decrease in intensity and stabilized until the advent of the de-escalation phase.
Moving now back to the evidence obtained on spatial dependence, and putting two and two together, our results seem to point to the early spatial contagion processes having triggered a kind of 'knock-on effect' for positive spatial dependence that resulted in a further propagation of the disease across space, while the reverse effect took place once these processes started to fade and became more localized during the de-escalation phase.
Now, looking at the state-by-state indexes, we can determine what type of municipality was more exposed to spatial contagion. As we can see, just before the lockdown, municipalities with no, low or very low COVID-19 risk were virtually the only ones exposed to contagion processes (values marked in bold in Table 2a). As expected, this picture changed in the lockdown, and spatial contagion spread to all types of municipalities (Table 2b). In contrast, in the de-escalation phase, transmission processes were more localized, with medium-risk municipalities being the most exposed (Table 2c-e).

| Spread drivers: Conditional spatial contagion index
To complete these results in terms of causality, we next consider the potential influence of some variables linked to community propagation, such as mobility, population and population density, as well as several indicators of social vulnerability, such as gross disposable income and immigration. While the potential influence of the first three variables is straightforward, regarding the latter two it is important to keep in mind that recent studies have highlighted that the unequal distribution of the COVID-19 outcomes across territories is closely related to economic and social inequalities, with poor and racially segregated places bearing the brunt of the pandemic's burden (Baena-Díez et al., 2020;Kim & Bostwick, 2020). We speculate that contagion between territories occurs through mobility, but, once it has occurred, the intensity of contagion depends on the characteristics of each territory, captured by population, population density, income and immigration.
As mentioned in the previous section, we computed the new conditional indexes, which must be compared with the previously calculated unconditional ones (Table 3). The Anderson and Goodman (1957) test was applied for each factor f to determine whether the spatial transition probabilities conditioned by factor f are not statistically different from those obtained without its influence. 7 The null hypothesis is mostly rejected at p < 0:01, reflecting the importance of these factors, with only two exceptions. First, for the gross disposable income variable, regardless of the period/sub-period. This result, albeit apparently puzzling, reveals that this type of contagion makes no significant distinction between poor and rich municipalities. Second, for the mobility variable, but restricted to the sub-periods covering the de-escalation phases. This result, paradoxically, reinforces the importance of mobility, since it simply reflects that the state of alarm managed to reduce it to a minimum.
In addition, the comparison of contagion indexes between factors also reveals that inter-municipal daily mobility stands out as the main driver of spatial contagion over the whole period, followed at some distance by population density. For sub-periods, daily mobility plays a major role in the evolution of spatial contagion processes only before and during the lockdown, while it becomes negligible throughout the de-escalation phase. This confirms that population mobility in the weeks before the lockdown correlates with spatial contagion levels during the lockdown, while its influence declines afterwards.
Finally, our results seem to reveal that the influence of factors such as population, population density and immigration varies greatly over time. While their influence is, to a greater or lesser extent, positive before the lockdown, it becomes negative from then on. This reveals that densely populated municipalities with a large immigrant community stand out as the areas most exposed to spatial contagion processes in the early stage of the pandemic. However, owing to mobility restrictions and the propagation of the pandemic to other areas of the region, this situation reverses over time, with the less densely populated areas and those with smaller immigrant communities becoming the most exposed.

| CONCLUSIONS
The current COVID-19 pandemic represents an exceptionally complex phenomenon, in which spatial interactions play a major role in its spread through a territory. This paper explored the real dimension, as well as the main driving forces, of the spatial contagion of the COVID-19 across the municipalities of the region of Madrid, one of the European regions most severely impacted during the first wave of the pandemic. To do so, we proposed a modified spatial Markov chain approach based on the estimation of an unconditional and a conditional spatial contagion index.
Accordingly, the two major strengths of the approach are that, on the one hand, it provides a quantitative basis for the rapid detection of high levels of spatial contagion between territories and, on the other hand, it reveals the potential factors contributing to the spatial spread of the disease from high to low incidence areas within a territory.
In this regard, it is worth pointing out that our unconditional contagion indicator revealed the presence of high levels of spatial contagion even before the declaration of the national lockdown, which suggests that the measures were late in coming. Consequently, the computation of a spatial contagion index as the one proposed in the paper could, together with other factors, form part of an early detection system for pandemics, and thus shed light on the need to impose containment measures. Our estimates also confirmed high levels of spatial contagion during the lockdown, which did not diminish and stabilize until well into the de-escalation phase established by the Spanish government as a bridge to the 'new normality'. Regarding the main factors behind spatial contagion, the analysis first showed that high inter-municipal mobility prior to confinement acted as a breeding ground for the presence of positive spatial dependence in subsequent cumulative incidence and, in consequence, for the emergence of major hotspots of COVID-19. The conditional spatial contagion index also demonstrated that densely populated municipalities with a large immigrant community were the areas most exposed to spatial contagion processes in the early phase of the pandemic in Madrid.
T A B L E 3 Cumulative incidence of COVID-19 in Madrid: Explanatory analysis based on conditional spatial contagion indexes C kjf t,t þ 7 ð Þ The analysis carried out in this study reveals the need for greater anticipatory power on the part of the authorities when faced with a pandemic, since, as indicated, the measures arrived too late, a conclusion that is valid not only for Madrid but also for many other cases. Moreover, our results call for mobility measures focused on densely populated municipalities with large immigrant communities. Combining the above, a possible strategy, based on frequent counting of these contagion indicators, would consist of imposing mobility restrictions in the most densely populated areas with the highest share of immigrants if the spatial contagion index were to show systematic increases. Should this trend not be curbed, it would be necessary to impose global containment, which, as the paper shows, is effective at controlling pandemics.
d. The trickiest situation we tackle is when mobility data are given, literally, for 'a specific municipality (any) and others'. This situation occurs in 14 cases. Here we, first, collect those municipalities without data (that is, under the umbrella of 'others' in INE's mobility areas) and, second, assign each to the nearest 'specific' municipality.
e. Finally, for the case of the municipality of Madrid, although we are already using data at the district level owing to its size, original data are offered here at the census area level. Here, we group all census data that corresponded to each of the 21 districts making up the municipality, calculating mean values between them.